Skip to content

Addressed review in #1247#1263

Merged
VisLab merged 2 commits intohed-standard:mainfrom
VisLab:fix_extras
Mar 12, 2026
Merged

Addressed review in #1247#1263
VisLab merged 2 commits intohed-standard:mainfrom
VisLab:fix_extras

Conversation

@VisLab
Copy link
Member

@VisLab VisLab commented Mar 11, 2026

No description provided.

@github-actions
Copy link

Review Summary

This PR consolidates redundant HedExceptions aliases into their canonical forms and fixes several real bugs. The cleanups are good, but the alias removal is incomplete and introduces four new AttributeError crash paths.


Critical — will crash at runtime

1. HedExceptions.SCHEMA_ATTRIBUTE_INVALID doesn't exist (base2schema.py:197)
SCHEMA_ATTRIBUTE_INVALID lives on SchemaAttributeErrors (in error_types.py), not on HedExceptions. Replace with HedExceptions.SCHEMA_LIBRARY_INVALID or import SchemaAttributeErrors and use the correct class.

2. HedExceptions.LIBRARY_SCHEMA_INVALID doesn't exist (base2schema.py:226)
The constant is SCHEMA_LIBRARY_INVALID (word order is reversed). One-character rename.

3. IN_LIBRARY_IN_UNMERGED removed but still used in three files
The constant was deleted from HedExceptions, but these call sites were not updated:

  • hed/schema/schema_io/xml2schema.py:351
  • hed/schema/schema_io/df2schema.py:278
  • hed/schema/schema_io/wiki2schema.py:612

All three need HedExceptions.IN_LIBRARY_IN_UNMERGEDHedExceptions.SCHEMA_LIBRARY_INVALID.

4. INVALID_LIBRARY_PREFIX removed but still used
Deleted from HedExceptions, but hed/schema/hed_schema.py:426 still references it.
Replace with HedExceptions.SCHEMA_LIBRARY_INVALID.


Confirmed good fixes in this PR

  • ONSET_TOLERANCE = 10 - 7 (evaluates to 3) → 1e-7 — correct scientific-notation literal
  • self.tag_dict[tag].value_dict + val_countself.tag_dict[tag].value_dict[value] + val_count — correct subscript in dict merge
  • Missing closing ' in two val_error_def_* messages
  • Stray } in bids_dataset.py error string
  • Regex compiled to module-level COLUMN_REF_PATTERN constant
  • Removal of make_path (function had no return statement, always returned None)
  • Dead commented-out code removed

The alias consolidation approach is correct; it just needs the four call sites above updated before merging.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR appears to follow up on review feedback from #1247 by standardizing schema-related error codes/messages, cleaning up dead/commented code, and making a few small validator/analysis fixes.

Changes:

  • Consolidates multiple schema/header/library error codes into fewer canonical HedExceptions codes and updates tests accordingly.
  • Refactors/cleans up validators and tools (e.g., precompiled column-ref regex, removes unused make_path, removes commented code).
  • Fixes a few correctness issues in analysis/utilities (e.g., tag count merge bug, onset tolerance constant, error message typos).

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/schema/test_schema_wiki_fatal_errors.py Updates expected fatal error codes for wiki schema header cases.
tests/schema/test_hed_schema_io.py Updates prerelease-partner tests/docs to assert the new error code.
spec_tests/test_hed_cache.py Updates expected exception code for invalid merged schema load cases.
hed/validator/util/group_util.py Removes unused commented-out validator hooks.
hed/validator/spreadsheet_validator.py Fixes onset tolerance constant to a small float tolerance.
hed/validator/sidecar_validator.py Precompiles the column reference regex and reuses it.
hed/validator/def_validator.py Removes commented-out unit validation code.
hed/tools/util/io_util.py Removes the unused make_path helper.
hed/tools/bids/bids_dataset.py Fixes an error message typo (extra }).
hed/tools/analysis/hed_type_factors.py Normalizes factor encoding errors to raise HedFileError and fixes a doc typo.
hed/tools/analysis/hed_tag_counts.py Fixes merge logic when summing per-value counts.
hed/tools/analysis/annotation_util.py Removes large blocks of commented-out legacy helpers.
hed/tools/init.py Stops exporting make_path (aligned with its removal).
hed/schema/schema_io/wiki2schema.py Uses SCHEMA_HEADER_INVALID for missing/invalid header line.
hed/schema/schema_io/base2schema.py Adjusts error codes for schema merge/load and rooted-tag validation paths.
hed/schema/schema_header_util.py Improves library-name validation messages and aligns error codes.
hed/schema/hed_schema_group.py Uses SCHEMA_LOAD_FAILED for duplicate namespace/prefix collisions.
hed/errors/exceptions.py Removes legacy/alias exception constants in favor of canonical codes.
hed/errors/error_messages.py Fixes missing trailing quote in formatted def/def-expand messages.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@github-actions
Copy link

PR Review summary: see inline comments. Critical fixes verified: ONSET_TOLERANCE (was 3, now 1e-7), dict+int TypeError in merge_tag_dicts, unclosed f-string quotes, wrong exception type in hed_type_factors. One important issue flagged via inline comment on exceptions.py (public API break from removing HedExceptions aliases). One suggestion flagged via inline comment on test_hed_schema_io.py (misleading comment references non-existent LIBRARY_SCHEMA_INVALID constant).

@VisLab VisLab merged commit 2a70f47 into hed-standard:main Mar 12, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants